﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace TestForm
{
    public class culInfo : IComparable
    {
        public CultureInfo ci;
        public override string ToString()
        {
            return ci.DisplayName + " (" + ci.IetfLanguageTag + ")";
        }

        #region IComparable Members
        public int CompareTo(object obj)
        {
            if (obj is culInfo)
            {
                culInfo otherTemperature = (culInfo)obj;
                return this.ci.DisplayName.CompareTo(otherTemperature.ci.DisplayName);
            }
            else
            {
                throw new ArgumentException("object is not a Temperature");
            }
        }
        #endregion
    }

    public class langList
    {
        public static List<culInfo> Gismeteo
        {
            get
            {
                string[] lList = new string[] { "ru", "en", "uk", "lt", "be", "ro"};
                List<culInfo> cil = new List<culInfo>();

                foreach (String s in lList)
                    foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
                        if (ci.IetfLanguageTag.ToLower().IndexOf(s.ToLower()) >= 0)
                        {
                            cil.Add(new culInfo() { ci = ci });
                            break;
                        }
                cil.Sort();
                return cil;
            }
        }

        public static List<culInfo> OpenWeatherMap
        {
            get
            {
                string[] lList = new string[] { "ru", "en", "de", "fr", "es", "it" };
                List<culInfo> cil = new List<culInfo>();

                foreach (String s in lList)
                    foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
                        if (ci.IetfLanguageTag.ToLower().IndexOf(s.ToLower()) >= 0)
                        {
                            cil.Add(new culInfo() { ci = ci });
                            break;
                        }
                cil.Sort();
                return cil;
            }
        }


        public static List<culInfo> AccuWeather
        {
            get
            {
                string[] lList = new string[] { "ca", "cs", "da", "de", "en-gb", "es-ar", "es-mx", "es", "fr-ca", "fr", "it", "hu", "nl", "no", "pl", "pt-br", "pt", "ro", "ru", "sv", "fi", "sk", "ar", "zh-cn", "zh-tw", "zh-hk", "el", "ja", "ko", "hi", "he", "en-US" };
                List<culInfo> cil = new List<culInfo>();

                foreach (String s in lList)
                    foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
                        if (ci.IetfLanguageTag.ToLower().IndexOf(s.ToLower()) >= 0)
                        {
                            cil.Add(new culInfo() { ci = ci });
                            break;
                        }
                cil.Sort();
                return cil;
            }
        }

        public static List<culInfo> RP5
        {
            get
            {
                string[] lList = new string[] { "ru", "en", "de", "es", "ua", "pt", "fr", "ro", "kz", "cn", "il" };
                List<culInfo> cil = new List<culInfo>();

                foreach (String s in lList)
                    foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
                        if (ci.IetfLanguageTag.ToLower().IndexOf(s.ToLower()) >= 0)
                        {
                            cil.Add(new culInfo() { ci = ci });
                            break;
                        }
                cil.Sort();
                return cil;
            }
        }

        public static List<culInfo> Foreca
        {
            get 
            {
                string[] lList = new string[]{"pt-pt", "pt-br","ru","ar","bn","bg","cs","da","de",
                    "et","el","es", "fr", "gu", "hi","hr","kn","lt","hu","ml",
                    "is","it","nl","ja","pl","pa","ro","sr","fi","sv","ta","te","tr","th","uk","sq","lv", "en"};
                List<culInfo> cil = new List<culInfo>();
                
                foreach (String s in lList)
                    foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
                        if (ci.IetfLanguageTag.ToLower().IndexOf(s.ToLower()) >= 0)
                        {
                            cil.Add(new culInfo() { ci = ci });
                            break;
                        }
                cil.Sort();
                return cil;
            }
        }
        public static List<culInfo> FreeMeteo
        {
            get
            {
                string[] lList = new string[]{"Arabic", "Bulgarian", "Catalan", "Chinese",
                    "Croatian", "Czech", "Danish", "Dutch", "English", "Finnish", "French",
                    "German", "Greek", "Hungarian", "Italian", "Norwegian", "Polish", "Portuguese",
                    "Romanian", "Russian", "Serbian", "Spanish", "Swedish", "Turkish"};
                List<culInfo> cil = new List<culInfo>();
                foreach(String s in lList)
                    foreach(CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
                        if (ci.EnglishName.ToLower().IndexOf(s.ToLower()) >= 0)
                        {
                            cil.Add(new culInfo() { ci = ci });
                            break;
                        }
                cil.Sort();
                return cil;
            }
        }
    }

    public class F
    {
        //public WeatherClockWidget.Domain.CityLocation cl;
        //public override string ToString()
        //{
        //    return cl.City;
        //}
    }

    public class F1
    {
        public Weather.Base.LocationData ld;
        public override string ToString()
        {
            return ld.City + " - " + ld.Country;
        }
    }
}
